package schedule.way_thread;

import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

/**
 * 多线程定时任务@Async
 */
@Configuration
@EnableScheduling
@EnableAsync//开启多线程
public class multiThreadScheduleTask {

    @Async//多线程
    @Scheduled(fixedDelay = 1000)
    public void first() {
        //System.out.println("第1个定时任务:" + LocalDateTime.now());
    }

    @Async//多线程
    @Scheduled(fixedDelay = 2000)
    public void second() {
        //System.out.println("第2个定时任务:" + LocalDateTime.now());
    }


}
